package stardust.product.j2d;

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.IOException;
import java.util.Random;

import javax.swing.JFrame;

import stardust.product.j2d.chart.LineChart;

public class Main {
	
	public static void main(String[] args) throws IOException, InterruptedException
	{
		JFrame f = new JFrame();
		f.setIgnoreRepaint(true);
//        f.setUndecorated(true);
		f.setLayout(new BorderLayout());
        f.setSize(500, 500);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setVisible(true);
		
		int w = 300;
		int h = 200;
		GraphicsContainer gc = GraphicsContainer.getSimpleGraphicsContainer(w, h);
		f.add(gc);
//		gc.setLocation(100, 50);
		gc.initialize();
		
		LineChart lc = new LineChart(0, 0, w, h);
		LineChart.LineData lcd = new LineChart.LineData();
		LineChart.LineData lcd2 = new LineChart.LineData();
		lcd.color = Color.GREEN;
		lcd2.color = Color.YELLOW;
		lc.getData().add(lcd);
		lc.getData().add(lcd2);
		gc.getRootGraphicsObject().getGraphicsObjects().add(lc);

		lcd.length = lcd2.length = lc.getMaxLength();
		
		while (true)
		{
			lcd.add(new Random().nextInt(100));
			lc.getData().add(lcd);
			
			lcd2.add(new Random().nextInt(100));
			lc.getData().add(lcd2);
			
			gc.refresh();
			Thread.sleep(500);
		}
	}

}
